var i;
function setDate() {
    var Dtime = document.getElementById("Dtime").innerText;
    var groupId = document.getElementById("groupId").innerText;
    var score = document.getElementById("score").innerText;
    var rscore = document.getElementsByName("rScore");
    if (score != "未批改") {
    for (var i = 0; i < rscore.length; i++) {
        if (rscore[i].value == score) {
            rscore[i].checked = 'checked';
        }
    }
    }
    ajaxCall("GET",path+"/QuestionServlet?method=getContentByDate&date="+Dtime,setQuestion);
    ajaxCall("Get",path+"/TeamExamTransactionServlet?method=setFileName&Dtime="+Dtime+"&groupId="+groupId,sFileName);
}
function setDate1(){
    var Dtime=document.getElementById("Dtime").innerText;
    var groupId=document.getElementById("groupId").innerText;

    ajaxCall("GET",path+"/QuestionServlet?method=getContentByDate&date="+Dtime,setQuestion);
    ajaxCall("Get",path+"/TeamExamTransactionServlet?method=setFileName&Dtime="+Dtime+"&groupId="+groupId,sFileName);
}

function setScore() {
    var radio = document.getElementsByName("rScore");
    for (i=0; i<radio.length; i++) {
        if (radio[i].checked) {
            var score=radio[i].value;
        }
    }
    var Dtime=document.getElementById("Dtime").innerText;
    var groupId=document.getElementById("groupId").innerText;
    var top=parseInt(document.getElementById("top").innerText);
    if(top==1&&score==5){
        alert("已经存在5分小组！");
        return;
    }
    ajaxCall("GET",path+"/TeamExamTransactionServlet?method=setScore&score="+score+"&groupId="+groupId+"&Dtime="+Dtime,setScoreResult);
}

function sFileName(res){
    var obj=JSON.parse(res);
    if(obj==null||obj==""){
        var div=document.getElementById("divFile");
        div.style.display="block";
        return;
    }
    for(i in obj) {
        var fileNames = document.getElementById("fileNames");
        var odiv=document.getElementById("myContent");
        if (i == 0) {
            fileNames.innerHTML += "<li class='active'><a href='#"+i+"' data-toggle='tab'>"+ obj[i].fileName +"</a></li>";
            odiv.innerHTML +="<div class='tab-pane fade in active' id='"+i+"'><pre>"+obj[i].workContent+"</pre></div>";
        }
        else {
            fileNames.innerHTML += "<li><a href='#"+i+"' data-toggle='tab'>"+ obj[i].fileName+"</a></li>";
            odiv.innerHTML+="<div class='tab-pane fade' id='"+i+"'><pre>"+obj[i].workContent+"</pre></div>";
        }
    }
}
function setScoreResult(res) {
    var obj=JSON.parse(res);
    if(obj){
        window.location.href="lookTeamExam.jsp";
    }
    else{
        alert("set score error");
    }
}
function setQuestion(res){
    var obj = JSON.parse(res);
    var tquestion=document.getElementById("tquestion");
    tquestion.value =obj;
}
